// =====================================================================
// <copyright file="ConfigExtensionsTest.cs" author="David R. Guindo">
// 	Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace System
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class ConfigHelperExtensionsTest
    {
        [TestMethod]
        public void AppSettingsGet_name_Test()
        {
            Assert.AreEqual(1, "intvalue".AppSettingsGet(0));
            Assert.AreEqual("value", "stringvalue".AppSettingsGet<string>());
            Assert.AreEqual("null", "nullvalue".AppSettingsGet<string>());
            Assert.AreEqual("", "emptyvalue".AppSettingsGet<string>());
            Assert.AreEqual(DateTime.Parse("1/1/2000"), "datetimevalue".AppSettingsGet<DateTime>());
            Assert.AreEqual(true, "boolvalue".AppSettingsGet<bool>());
        }

        [TestMethod]
        public void AppSettingsGet_noValue_Test()
        {
            Assert.AreEqual("novalue", "novalue".AppSettingsGet<string>("novalue"));
        }

        [TestMethod]
        public void AppSettingsGet_defaultValue_Test()
        {
            Assert.AreEqual(default(string), "novalue".AppSettingsGet<string>());
            Assert.AreEqual(default(int), "novalue".AppSettingsGet<int>());
            Assert.AreEqual(default(bool), "novalue".AppSettingsGet<bool>());
        }
    }
}